<template>
	<view>
		<view v-for="item in infolist" :key="item._id">
			<resumeinfo @deletes="deletes" :item="item"></resumeinfo>
		</view>
		<u-modal @cancel="cancel" @confirm="confirm" :showCancelButton="true" confirmText="确认删除" :show="immediate"
			title="您将要删除" :content='content'></u-modal>
		<view class="nomore" v-if="isnomore">
			<text>暂未投递</text>
		</view>
	</view>
</template>

<script>
	const db = uniCloud.database()
	export default {
		data() {
			return {
				infolist: [],
				isnomore: false,
				zp_id: '',
				content: '',
				immediate: false
			};
		},
		onLoad() {
			this.getmylist()
		},
		methods: {
			cancel() {
				this.immediate=false
				
			},
			confirm(){
				uni.showLoading({
					title:"删除中"
				})
				db.collection("resume").where({
					"_id":this.zp_id
				}).remove().then(res=>{
					console.log("删除成功")
				})
				uni.hideLoading()
				this.getfilters()
				uni.showToast({
					title:"删除成功"
				})
					this.immediate=false
			},
			async getmylist() {
				await db.collection("resume").where({
					user_id: uniCloud.getCurrentUserInfo().uid
				}).get().then(res => {
					console.log(res, "这些")
					this.infolist = res.result.data
					if (res.result.data.length == 0) {
						this.isnomore = true
					}
				})
			},
			deletes(e) {
				this.zp_id = e[0]
				this.content = e[1]
				this.immediate=true
				console.log(e)
			},
			//无感删除
			getfilters() {
				console.log('执行了')
				this.infolist = this.infolist.filter(item => {
					return item._id != this.zp_id
				})
				if(this.infolist.length==0){
					this.isnomore=true
				}else{
					this.isnomore=false
				}
			}
		}
	}
</script>

<style lang="scss">
	.nomore {
		margin-top: 50rpx;
		display: flex;
		justify-content: center;
		color: #F7E7CE;
		font-size: 40rpx;
	}
</style>
<style>
	page {
		background-color: #11265c;
	}
</style>